package com.esun.service.mq.producer;

import org.apache.rocketmq.common.message.MessageConst;
import org.springframework.boot.CommandLineRunner;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * mongodb消息队列发送类
 * @author John.xiao
 * @date 2021/9/2 0:41
 */
@Component
public class MongodbRunner  {
    @Resource
    private MessageChannel output;

    public void send(String info){
        Map<String,Object> headers = new HashMap<>(10);
        headers.put(MessageConst.PROPERTY_MAX_RECONSUME_TIMES,3);
        headers.put(MessageConst.PROPERTY_MAX_OFFSET,3);
        Message message = MessageBuilder.createMessage(info,new MessageHeaders(headers));
        output.send(message);
    }


}
